package com.my12306.train.controller;

import com.my12306.common.util.PageUtils;
import com.my12306.common.util.response.ResponseData;
import com.my12306.train.model.entity.CariageMarshallingRelationEntity;
import com.my12306.train.model.vo.CarriageMarshallingRelationVo;
import com.my12306.train.service.CariageMarshallingRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 编组与车厢的关联表
 *
 * @author ËÕÄÁÏ¦
 * @email
 * @date 2020-07-24 20:58:07
 */
@RestController
@RequestMapping("/cariagemarshallingrelation")
public class CariageMarshallingRelationController {
    @Autowired
    private CariageMarshallingRelationService cariageMarshallingRelationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResponseData list(@RequestParam Map<String, Object> params) {
        PageUtils page = null;
        return ResponseData.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public ResponseData info(@PathVariable("id") Long id) {
        CariageMarshallingRelationEntity cariageMarshallingRelation = cariageMarshallingRelationService.getById(id);

        return ResponseData.ok().put("cariageMarshallingRelation", cariageMarshallingRelation);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public ResponseData save(@RequestBody CarriageMarshallingRelationVo carriageMarshallingRelationVo) {
        cariageMarshallingRelationService.saveCarriageMarshallingRelation(carriageMarshallingRelationVo);
        return ResponseData.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public ResponseData update(@RequestBody CarriageMarshallingRelationVo carriageMarshallingRelationVo) {
        cariageMarshallingRelationService.updateCarriageMarshallingRelation(carriageMarshallingRelationVo);
        return ResponseData.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public ResponseData delete(@RequestBody List<Long> ids) {
        System.out.println("即将删除的ids："+ids);
        cariageMarshallingRelationService.deleteMarshallingBatchByIds(ids);

        return ResponseData.ok();
    }

}
